﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace SCCM
{
    public partial class UcChartInfo : UserControl
    {
        private System.Windows.Forms.DataVisualization.Charting.Chart chart1;



        public UcChartInfo()
        {
            InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

       

        private void UpdateChartSettings()
        {
            chart1.Series["Series1"].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), "Line", true);
            chart1.Series["Series1"].SmartLabelStyle.Enabled = true;
            chart1.Series["Series1"].IsValueShownAsLabel = true;
            chart1.Series["Series1"].IsXValueIndexed = false;
            chart1.ChartAreas["Default"].AxisX.IsMarginVisible = false;
            chart1.ChartAreas["Default"].AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None;
            chart1.ChartAreas["Default"].AxisX.LabelStyle.IsStaggered = false;
            chart1.ChartAreas[0].AxisX.Crossing = 0;

        }

        private void UcChartInfo_Load(object sender, EventArgs e)
        {

        }

        public void BindDataInfo(List<ChartLactionInfo> lst)
        {
            DateTime baseDate = DateTime.Today;
            chart1.Series["Series1"].Points.Clear();
            for (int i = 0; i < lst.Count; i++)
            {
                chart1.Series["Series1"].Points.AddXY(lst[i].XDate, lst[i].YValue);
            }

            UpdateChartSettings();
        }
    }

    public class ChartLactionInfo
    {
        public DateTime XDate { get; set; }
        public double YValue { get; set; }
    }
    
}
